﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExternalConnections.CUiCOpcUAConnectionForm
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using DnProcessSimulateCommands.ExternalConnections.Res;
using EngineeringInternalExtension;
using Opc.Ua;
using Opc.UA.Server.API;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Net;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;
using UiInternalControls;
using UiInternalControls.GeneralWindowsControls;


namespace DnProcessSimulateCommands.ExternalConnections;

public class CUiCOpcUAConnectionForm : TxForm
{
  private CApECExternalConnectionsManager m_dataMgr;
  private CApECOpcUAConnectionFormParams m_params;
  private int m_suspendEnablersCounter;
  private EndpointWrapper m_selectedEndPointWrapper;
  private bool _isAdvancedMode;
  private OpcUAServer m_Server;
  private bool m_Connected;
  private ToolTip _buttonToolTip = new ToolTip();
  private ToolTip _infoToolTip = new ToolTip();
  private string _opcUACaption;
  private IContainer components;
  private Label _connectionNameLabel;
  private TextBox _connectionName;
  private Label endpointLabel;
  private TextBox _endPoint;
  private Label _nameSpaceIndexLabel;
  private Button _cancelButton;
  private Button _okButton;
  private NumericTextBox _nameSpaceIndex;
  private Panel _simpleModePanel;
  private Button _advancedButton;
  private Panel _advancedPanel;
  private BrowseControl _nameSpaceIndexBrowser;
  private ComboBox _endPointsComboBox;
  private Label _endPointslabel;
  private Button _refreshButton;
  private TextBox _hostName;
  private Label _hostNameLabel;
  private Label borderlabel;
  private Label _portLabel;
  private NumericTextBox _port;
  private ImageList m_formImageList;
  private PictureBox m_warningPictureBox;
  private Label m_itemHeaderLabel;
  private TextBox _itemHeader;
  private TxInfoButton m_infoBox;
  private Panel _warningPanel;
  private TextBox _warningTextBox;
  private Button _browseButton;

  public CUiCOpcUAConnectionForm(CApECExternalConnectionsManager mgr)
  {
    this.InitializeComponent();
    this._infoToolTip.AutoPopDelay = 30000;
    this._infoToolTip.InitialDelay = 500;
    this._infoToolTip.ReshowDelay = 150;
    this._infoToolTip.ShowAlways = true;
    this._nameSpaceIndexBrowser.SelectionChanged += new BrowseControl.SelectionChangedEventHandler(this.browserControl_SelectionChanged);
    this.m_Server = new OpcUAServer();
    // ISSUE: method pointer
    this.m_Server.CertificateEvent += new certificateValidation((object) this, __methodptr(m_Server_CertificateEvent));
    this._port.Enter += new EventHandler(this.OnEnterPort);
    this.m_dataMgr = mgr;
  }

  private void InitAdvancedMode()
  {
    ITxPlcExternalConnectionDataEx data = (ITxPlcExternalConnectionDataEx) null;
    if (this.m_params.DialogMode == CApECOpcUAConnectionFormParams.eMode.Create)
      data = (ITxPlcExternalConnectionDataEx) new TxPlcOpcUAConnectionDataEx();
    else if (this.m_params.DialogMode == CApECOpcUAConnectionFormParams.eMode.Edit)
      data = this.m_params.ConnectionToEdit.Data;
    this.InitAdvancedUiByData(data, false);
  }

  private void InitAdvancedUiByData(ITxPlcExternalConnectionDataEx data, bool updateEnablers)
  {
    if (data == null)
      return;
    IApECExternalConnectionDataConvertor instance = this.m_params.DataConvertor.CreateInstance(data);
    if (!(CApECExternalConnectionsManager.GetConnectionTypeFromData(data) == CUiECExternalConnectionsResourceTable.OPC_UA_TYPE))
      return;
    Cursor current = Cursor.Current;
    Cursor.Current = Cursors.WaitCursor;
    CApECExternalConnectionDataEditConvertor dataEditConvertor = (CApECExternalConnectionDataEditConvertor) instance;
    this._endPointsComboBox.Text = dataEditConvertor.OpcServer as string;
    this._hostName.Text = Dns.GetHostName();
    this._port.Text = dataEditConvertor.OpcServerPort as string;
    if (this._port.Text.Equals(""))
      this._port.Text = "4840";
    if (dataEditConvertor.OpcServerEndPointUrl is string && dataEditConvertor.OpcServerEndPointUrl is string && !(dataEditConvertor.OpcServerEndPointUrl as string).Equals(string.Empty) && dataEditConvertor.OpcServerEndPointUrl is string serverEndPointUrl && serverEndPointUrl.Length > 10)
    {
      string[] strArray = serverEndPointUrl.Substring(10).Split(':');
      if (strArray.Length > 1)
        this._hostName.Text = strArray[0];
    }
    Cursor.Current = current;
  }

  private void InsertSelectedEndPointDescription(string endPointName, string endPointUrl)
  {
    bool flag = false;
    foreach (object obj in this._endPointsComboBox.Items)
    {
      EndpointWrapper endpointWrapper = obj as EndpointWrapper;
      if (endpointWrapper.endPointName.Equals(endPointName) && endpointWrapper.endPointUrl.Equals(endPointUrl))
      {
        this._endPointsComboBox.SelectedItem = (object) endpointWrapper;
        flag = true;
      }
    }
    if (flag || this._endPointsComboBox.Items.Count <= 0)
      return;
    this._endPointsComboBox.SelectedIndex = 0;
  }

  [DllImport("user32.dll")]
  private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);

  protected virtual void OnLoad(EventArgs e)
  {
    this._buttonToolTip.SetToolTip((Control) this._browseButton, CUiECExternalConnectionsResourceTable.BROWSE_DOMAIN_CAPTION);
    this._infoToolTip.SetToolTip((Control) this.m_infoBox, CUiECExternalConnectionsResourceTable.OPC_UA_INFO_TOOLTIP);
    this.m_infoBox.TooltipText = CUiECExternalConnectionsResourceTable.OPC_UA_INFO_TOOLTIP;
    base.OnLoad(e);
  }

  internal DialogResult ShowDialog(CApECOpcUAConnectionFormParams formParams)
  {
    this.showSimpleMode();
    this.InitMode(formParams);
    this._buttonToolTip.SetToolTip((Control) this._refreshButton, CUiECExternalConnectionsResourceTable.RELOAD_CAPTION);
    return ((Form) this).ShowDialog();
  }

  private void InitMode(CApECOpcUAConnectionFormParams formParams)
  {
    this.m_params = formParams;
    this.SuspendUiEnablers();
    try
    {
      switch (this.m_params.DialogMode)
      {
        case CApECOpcUAConnectionFormParams.eMode.Edit:
          this.InitUiByData(this.m_params.ConnectionToEdit.Data, false);
          this._opcUACaption = CUiECExternalConnectionsResourceTable.EDIT_OPC_UA_CONNECTION_DLG_CAPTION;
          this._connectionName.Focus();
          this._connectionName.SelectAll();
          break;
        case CApECOpcUAConnectionFormParams.eMode.Create:
          this.InitUiByData((ITxPlcExternalConnectionDataEx) new TxPlcOpcUAConnectionDataEx(), false);
          this._opcUACaption = CUiECExternalConnectionsResourceTable.ADD_OPC_UA_CONNECTION_DLG_CAPTION;
          this._connectionName.Focus();
          break;
      }
      ((Control) this).Text = this._opcUACaption;
    }
    finally
    {
      this.ResumeUiEnablers();
    }
  }

  private void InitUiByData(ITxPlcExternalConnectionDataEx data, bool updateEnablers)
  {
    IApECExternalConnectionDataConvertor instance = this.m_params.DataConvertor.CreateInstance(data);
    if (CApECExternalConnectionsManager.GetConnectionTypeFromData(data) == CUiECExternalConnectionsResourceTable.OPC_UA_TYPE)
    {
      CApECExternalConnectionDataEditConvertor dataEditConvertor = (CApECExternalConnectionDataEditConvertor) instance;
      this._connectionName.Text = dataEditConvertor.Name as string;
      this._endPoint.Text = dataEditConvertor.OpcServer as string;
      if (dataEditConvertor.NameSpaceIndex != null && dataEditConvertor.NameSpaceIndex is string)
        this._nameSpaceIndex.Text = dataEditConvertor.NameSpaceIndex as string;
      this._itemHeader.Text = dataEditConvertor.ItemHeader as string;
    }
    if (!updateEnablers)
      return;
    this.UpdateAllEnablers();
  }

  private ITxPlcExternalConnectionDataEx RetrieveDataFromUi()
  {
    CApECExternalConnectionDataEditConvertor instance = (CApECExternalConnectionDataEditConvertor) this.m_params.DataConvertor.CreateInstance((ITxPlcExternalConnectionDataEx) new TxPlcOpcUAConnectionDataEx());
    instance.Name = (object) this._connectionName.Text;
    instance.OpcServer = (object) this._endPoint.Text;
    this.m_selectedEndPointWrapper = new EndpointWrapper(this._connectionName.Text, this._endPoint.Text);
    instance.OpcServerEndPointUrl = (object) this.m_selectedEndPointWrapper.endPointUrl;
    instance.OpcServerEndPointName = (object) this.m_selectedEndPointWrapper.endPointName;
    instance.NameSpaceIndex = (object) this._nameSpaceIndex.Text;
    instance.OpcServerPort = (object) this._port.Text;
    instance.ItemHeader = (object) this._itemHeader.Text;
    return instance.Data;
  }

  private bool EnablersSuspended() => this.m_suspendEnablersCounter > 0;

  private void SuspendUiEnablers() => ++this.m_suspendEnablersCounter;

  private void ResumeUiEnablers()
  {
    if (this.EnablersSuspended())
      --this.m_suspendEnablersCounter;
    if (this.EnablersSuspended())
      return;
    this.UpdateAllEnablers();
  }

  private void UpdateAllEnablers()
  {
    if (this.EnablersSuspended())
      return;
    this.UpdateEnabler_ButtonOK();
  }

  private void UpdateEnabler_ButtonOK()
  {
    if (this.EnablersSuspended())
      return;
    this._okButton.Enabled = this._connectionName.Text.Trim().Length > 0 && this._endPoint.Text.Trim().Length > 0 && this._nameSpaceIndex.Text.Trim().Length > 0;
  }

  private void PopulateEndPointsUrlList(bool setactiveUrl = true)
  {
    ((Control) this).Cursor = Cursors.WaitCursor;
    this._endPointsComboBox.Items.Clear();
    this._endPointsComboBox.Text = "";
    this._itemHeader.Text = "";
    this._nameSpaceIndex.Text = "";
    try
    {
      string hostName1 = Dns.GetHostName();
      string hostName2 = this._hostName.Text.Trim();
      Uri discoveryUrl;
      if (hostName2.Equals(hostName1) || hostName2.Equals(""))
      {
        discoveryUrl = new Uri(Utils.Format("opc.tcp://{0}:{1}", new object[2]
        {
          (object) hostName1,
          (object) this._port.Text
        }));
      }
      else
      {
        string str = "opc.tcp://";
        if (hostName2.StartsWith("//"))
          str = "opc.tcp:";
        char ch = ':';
        discoveryUrl = new Uri(hostName2.Split(ch).Length <= 1 ? $"{str}{hostName2}:{this._port.Text}" : str + hostName2);
      }
      this.GetEndpoints(discoveryUrl, hostName2);
      if (this._endPointsComboBox.Items.Count > 0)
      {
        if (setactiveUrl)
          this._endPointsComboBox.SelectedIndex = 0;
      }
      else
        this.clearNameSpaceIndexBrowser();
      ((Control) this).Cursor = Cursors.Default;
    }
    catch (Exception ex)
    {
      int num = (int) TxMessageBox.ShowModal(CUiECExternalConnectionsResourceTable.OPCUA_WRON_IP_FORMAT, this._opcUACaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
      ((Control) this).Cursor = Cursors.Default;
    }
  }

  private void GetEndpoints(Uri discoveryUrl, string hostName)
  {
    EndpointDescriptionCollection descriptionCollection1 = (EndpointDescriptionCollection) null;
    try
    {
      ApplicationDescriptionCollection descriptionCollection2 = (ApplicationDescriptionCollection) null;
      Discovery discovery = new Discovery();
      discovery.FindServers(discoveryUrl, ref descriptionCollection2);
      for (int index = 0; index < ((List<ApplicationDescription>) descriptionCollection2).Count; ++index)
      {
        try
        {
          if (((List<ApplicationDescription>) descriptionCollection2)[index].ApplicationType != 3)
          {
            string uriString = ((List<string>) ((List<ApplicationDescription>) descriptionCollection2)[index].DiscoveryUrls)[0];
            foreach (string discoveryUrl1 in (List<string>) ((List<ApplicationDescription>) descriptionCollection2)[index].DiscoveryUrls)
            {
              if (discoveryUrl1 != null && discoveryUrl1.StartsWith("opc.tcp://"))
                uriString = discoveryUrl1.Replace("localhost", hostName);
            }
            if (uriString != null)
              discoveryUrl = new Uri(uriString);
            discovery.GetEndpoints(discoveryUrl, ref descriptionCollection1);
            foreach (EndpointDescription endpointDescription in (List<EndpointDescription>) descriptionCollection1)
            {
              if (endpointDescription.EndpointUrl.StartsWith("opc.tcp://"))
              {
                endpointDescription.EndpointUrl = endpointDescription.EndpointUrl.Replace("localhost", hostName);
                char ch = '#';
                string str = endpointDescription.SecurityPolicyUri.Split(ch)[1] + ", " + endpointDescription.SecurityMode.ToString();
                EndpointWrapper endpointWrapper = new EndpointWrapper(endpointDescription.Server.ApplicationName.Text, endpointDescription.EndpointUrl);
                if (!this._endPointsComboBox.Items.Contains((object) endpointWrapper))
                  this._endPointsComboBox.Items.Add((object) endpointWrapper);
              }
            }
          }
        }
        catch (Exception ex)
        {
          int num = (int) TxMessageBox.ShowModal(CUiECExternalConnectionsResourceTable.OPCUA_CONNECTION_FAILS, this._opcUACaption, MessageBoxButtons.OK, MessageBoxIcon.Hand);
        }
      }
    }
    catch (Exception ex)
    {
      int num = (int) TxMessageBox.ShowModal(CUiECExternalConnectionsResourceTable.OPCUA_CONNECTION_ERROR, this._opcUACaption, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    }
  }

  private void PupulateNameSpaceIndexTree(string endpointUrl)
  {
    ((Control) this).Cursor = Cursors.WaitCursor;
    if (this.m_Connected)
    {
      this.Disconnect();
      this.clearNameSpaceIndexBrowser();
    }
    if (endpointUrl != null && endpointUrl != "")
    {
      this.Connect(endpointUrl);
      if (this.m_Connected)
        this._nameSpaceIndexBrowser.Browse((TreeNode) null);
    }
    ((Control) this).Cursor = Cursors.Default;
  }

  private void Connect(string Url)
  {
    try
    {
      this.m_Server.Connect(Url);
      this.m_Connected = true;
      this._nameSpaceIndexBrowser.Server = this.m_Server;
    }
    catch (Exception ex)
    {
      int num = (int) TxMessageBox.Show(CUiECExternalConnectionsResourceTable.CONNECTION_FAILED, this._opcUACaption, MessageBoxButtons.OK, MessageBoxIcon.Hand);
      if (this.m_Connected)
        this.Disconnect();
      this.m_Connected = false;
    }
  }

  private void Disconnect()
  {
    try
    {
      this.m_Server.Disconnect();
      this.m_Connected = false;
    }
    catch (Exception ex)
    {
      this.m_Connected = false;
      int num = (int) TxMessageBox.Show($"{CUiECExternalConnectionsResourceTable.DISCONNECTION_ERROR} {ex.Message}", this._opcUACaption, MessageBoxButtons.OK, MessageBoxIcon.Hand);
    }
  }

  private void browserControl_SelectionChanged(TreeNode node)
  {
    ReferenceDescription tag = (ReferenceDescription) node.Tag;
    string str1 = node.Tag.ToString();
    string str2 = tag.NodeId.Identifier.ToString();
    int startIndex = str2.IndexOf(str1);
    if (startIndex == -1)
      return;
    this._itemHeader.Text = str2.Remove(startIndex, str1.Length);
    this._nameSpaceIndex.Text = tag.NodeId.NamespaceIndex.ToString();
  }

  private void m_Server_CertificateEvent(
    CertificateValidator validator,
    CertificateValidationEventArgs e)
  {
    e.Accept = true;
  }

  private void _CancelButton_Click(object sender, EventArgs e)
  {
    ((Form) this).DialogResult = DialogResult.Cancel;
    if (((Form) this).Modal)
      return;
    ((Form) this).Close();
  }

  private void _okButton_Click(object sender, EventArgs e)
  {
    ((Form) this).DialogResult = DialogResult.OK;
    if (((Form) this).Modal)
      return;
    ((Form) this).Close();
  }

  private void CUiCOpcUAConnectionForm_FormClosing(object sender, FormClosingEventArgs e)
  {
    if (((Form) this).DialogResult == DialogResult.OK)
    {
      ITxPlcExternalConnectionDataEx connectionDataEx = this.RetrieveDataFromUi();
      switch (this.m_params.DialogMode)
      {
        case CApECOpcUAConnectionFormParams.eMode.Edit:
          CApECExternalConnectionsManager.eSetConnectionDataFailiureReason failiureReason1;
          if (!this.m_dataMgr.CanSetConnectionData(this.m_params.ConnectionToEdit, connectionDataEx, out failiureReason1))
          {
            e.Cancel = true;
            if (failiureReason1 == CApECExternalConnectionsManager.eSetConnectionDataFailiureReason.DuplicatedName)
            {
              int num = (int) MessageBox.Show(CUiECExternalConnectionsResourceTable.ERR_MSG_DUPLICATED_CONNECTION_NAME, ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
              break;
            }
            break;
          }
          break;
        case CApECOpcUAConnectionFormParams.eMode.Create:
          CApECExternalConnectionsManager.eCreateConnectionFailiureReason failiureReason2;
          if (!this.m_dataMgr.CanCreateConnectionWithData(connectionDataEx, out failiureReason2))
          {
            e.Cancel = true;
            if (failiureReason2 == CApECExternalConnectionsManager.eCreateConnectionFailiureReason.DuplicatedName)
            {
              int num = (int) MessageBox.Show(CUiECExternalConnectionsResourceTable.ERR_MSG_DUPLICATED_CONNECTION_NAME, ((Control) this).Text, MessageBoxButtons.OK, MessageBoxIcon.Hand);
              break;
            }
            break;
          }
          break;
      }
      if (!e.Cancel)
        this.m_params.DataToApply = connectionDataEx;
      else
        ((Form) this).DialogResult = DialogResult.Cancel;
    }
    if (this.m_Connected)
      this.Disconnect();
    this.OnClosing((CancelEventArgs) e);
  }

  private void _connectionName_TextChanged(object sender, EventArgs e)
  {
    this.UpdateEnabler_ButtonOK();
  }

  private void _endPoint_TextChanged(object sender, EventArgs e) => this.UpdateEnabler_ButtonOK();

  private void _nameSpaceIndex_TextChanged(object sender, EventArgs e)
  {
    this.UpdateEnabler_ButtonOK();
  }

  private void _browseButton_Click(object sender, EventArgs e)
  {
    Dns.GetHostName();
    using (TxFolderBrowserControl folderBrowserControl = new TxFolderBrowserControl())
    {
      BrowseFlags browseFlags = (BrowseFlags) 4096 /*0x1000*/;
      folderBrowserControl.BrowseFlags = browseFlags;
      RootNode rootNode = (RootNode) 18;
      folderBrowserControl.RootNode = rootNode;
      folderBrowserControl.Title = CUiECExternalConnectionsResourceTable.BROWSE_NETWORK_NEIGHBOURHOOD;
      if (!folderBrowserControl.ShowDialog())
        return;
      this._hostName.Text = folderBrowserControl.FolderDisplayName;
      this.PopulateEndPointsUrlList();
    }
  }

  private void OnEnterPort(object sender, EventArgs e)
  {
    if (e == EventArgs.Empty || ((KeyPressEventArgs) e).KeyChar != '\r')
      return;
    if (this._hostName.Text.Equals(""))
      this._hostName.Text = "//localhost";
    this.PopulateEndPointsUrlList();
  }

  private void _refreshButton_Click(object sender, EventArgs e) => this.PopulateEndPointsUrlList();

  private void advancedButton_Click(object sender, EventArgs e)
  {
    if (!this._isAdvancedMode)
      this.showAdvanceMode();
    else
      this.showSimpleMode();
    this.UpdateEnabler_ButtonOK();
  }

  private void _hostName_KeyPress(object sender, KeyPressEventArgs e)
  {
    // ISSUE: explicit non-virtual call
    __nonvirtual (((Control) this).OnKeyPress(e));
    if (e.KeyChar == '\r')
    {
      if (this._hostName.Text.Equals(""))
        this._hostName.Text = "//localhost";
      this.PopulateEndPointsUrlList();
    }
    else
    {
      if (e.KeyChar != '\\')
        return;
      e.Handled = true;
    }
  }

  private void showAdvanceMode()
  {
    this._isAdvancedMode = true;
    this.InitAdvancedMode();
    ((Control) this).MinimumSize = new Size(TxScaling.ScaleByDpi(440), TxScaling.ScaleByDpi(404));
    ((Control) this).MaximumSize = new Size(int.MaxValue, int.MaxValue);
    this._endPoint.Enabled = false;
    this._nameSpaceIndex.Enabled = false;
    this._advancedPanel.Visible = true;
    this._advancedButton.Image = this.m_formImageList.Images[0];
    this._buttonToolTip.SetToolTip((Control) this._advancedButton, CUiECExternalConnectionsResourceTable.SIMPLE_MODE);
  }

  private void showSimpleMode()
  {
    this._isAdvancedMode = false;
    ((Control) this).MinimumSize = new Size(TxScaling.ScaleByDpi(440), TxScaling.ScaleByDpi(220));
    ((Control) this).MaximumSize = new Size(int.MaxValue, TxScaling.ScaleByDpi(220));
    this._endPoint.Enabled = true;
    this._nameSpaceIndex.Enabled = true;
    this._advancedPanel.Visible = false;
    this._advancedButton.Image = this.m_formImageList.Images[1];
    this._buttonToolTip.SetToolTip((Control) this._advancedButton, CUiECExternalConnectionsResourceTable.ADVANCED_MODE);
  }

  private void clearNameSpaceIndexBrowser()
  {
    this._nameSpaceIndexBrowser.BrowseTree.BeginUpdate();
    this._nameSpaceIndexBrowser.BrowseTree.Nodes.Clear();
    this._nameSpaceIndexBrowser.BrowseTree.EndUpdate();
  }

  private void _endPointsComboBox_SelectedIndexChanged(object sender, EventArgs e)
  {
    if (this._endPointsComboBox.SelectedItem is EndpointWrapper selectedItem)
    {
      this._endPoint.Text = selectedItem.endPointUrl;
      this.PupulateNameSpaceIndexTree(selectedItem.endPointUrl);
    }
    else
    {
      this._endPoint.Text = "";
      this.clearNameSpaceIndexBrowser();
    }
  }

  protected virtual void Dispose(bool disposing)
  {
    if (disposing && this.components != null)
      this.components.Dispose();
    base.Dispose(disposing);
  }

  private void InitializeComponent()
  {
    this.components = (IContainer) new Container();
    ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (CUiCOpcUAConnectionForm));
    this._connectionNameLabel = new Label();
    this._connectionName = new TextBox();
    this.endpointLabel = new Label();
    this._endPoint = new TextBox();
    this._nameSpaceIndexLabel = new Label();
    this._cancelButton = new Button();
    this._okButton = new Button();
    this._simpleModePanel = new Panel();
    this.m_infoBox = new TxInfoButton();
    this._itemHeader = new TextBox();
    this.m_itemHeaderLabel = new Label();
    this._nameSpaceIndex = new NumericTextBox();
    this._advancedButton = new Button();
    this.m_formImageList = new ImageList(this.components);
    this._advancedPanel = new Panel();
    this._browseButton = new Button();
    this._port = new NumericTextBox();
    this._portLabel = new Label();
    this.borderlabel = new Label();
    this._nameSpaceIndexBrowser = new BrowseControl();
    this._endPointsComboBox = new ComboBox();
    this._endPointslabel = new Label();
    this._refreshButton = new Button();
    this._hostName = new TextBox();
    this._hostNameLabel = new Label();
    this.m_warningPictureBox = new PictureBox();
    this._warningPanel = new Panel();
    this._warningTextBox = new TextBox();
    this._simpleModePanel.SuspendLayout();
    this._advancedPanel.SuspendLayout();
    ((ISupportInitialize) this.m_warningPictureBox).BeginInit();
    this._warningPanel.SuspendLayout();
    ((Control) this).SuspendLayout();
    componentResourceManager.ApplyResources((object) this._connectionNameLabel, "_connectionNameLabel");
    this._connectionNameLabel.Name = "_connectionNameLabel";
    componentResourceManager.ApplyResources((object) this._connectionName, "_connectionName");
    this._connectionName.Name = "_connectionName";
    this._connectionName.TextChanged += new EventHandler(this._connectionName_TextChanged);
    componentResourceManager.ApplyResources((object) this.endpointLabel, "endpointLabel");
    this.endpointLabel.Name = "endpointLabel";
    componentResourceManager.ApplyResources((object) this._endPoint, "_endPoint");
    this._endPoint.Name = "_endPoint";
    this._endPoint.TextChanged += new EventHandler(this._endPoint_TextChanged);
    componentResourceManager.ApplyResources((object) this._nameSpaceIndexLabel, "_nameSpaceIndexLabel");
    this._nameSpaceIndexLabel.Name = "_nameSpaceIndexLabel";
    componentResourceManager.ApplyResources((object) this._cancelButton, "_cancelButton");
    this._cancelButton.DialogResult = DialogResult.Cancel;
    this._cancelButton.Name = "_cancelButton";
    this._cancelButton.UseVisualStyleBackColor = true;
    this._cancelButton.Click += new EventHandler(this._CancelButton_Click);
    componentResourceManager.ApplyResources((object) this._okButton, "_okButton");
    this._okButton.Name = "_okButton";
    this._okButton.UseVisualStyleBackColor = true;
    this._okButton.Click += new EventHandler(this._okButton_Click);
    componentResourceManager.ApplyResources((object) this._simpleModePanel, "_simpleModePanel");
    this._simpleModePanel.Controls.Add((Control) this.m_infoBox);
    this._simpleModePanel.Controls.Add((Control) this._itemHeader);
    this._simpleModePanel.Controls.Add((Control) this.m_itemHeaderLabel);
    this._simpleModePanel.Controls.Add((Control) this._endPoint);
    this._simpleModePanel.Controls.Add((Control) this._nameSpaceIndex);
    this._simpleModePanel.Controls.Add((Control) this.endpointLabel);
    this._simpleModePanel.Controls.Add((Control) this._nameSpaceIndexLabel);
    this._simpleModePanel.Controls.Add((Control) this._connectionName);
    this._simpleModePanel.Controls.Add((Control) this._connectionNameLabel);
    this._simpleModePanel.Name = "_simpleModePanel";
    componentResourceManager.ApplyResources((object) this.m_infoBox, "m_infoBox");
    ((Control) this.m_infoBox).Name = "m_infoBox";
    this.m_infoBox.TabStop = true;
    this.m_infoBox.TooltipDuration = 5000;
    this.m_infoBox.TooltipText = (string) null;
    this.m_infoBox.TooltipTitle = "";
    this.m_infoBox.Type = (TxInfoButton.InfoType) 0;
    componentResourceManager.ApplyResources((object) this._itemHeader, "_itemHeader");
    this._itemHeader.Name = "_itemHeader";
    componentResourceManager.ApplyResources((object) this.m_itemHeaderLabel, "m_itemHeaderLabel");
    this.m_itemHeaderLabel.Name = "m_itemHeaderLabel";
    this._nameSpaceIndex.AllowSpace = false;
    componentResourceManager.ApplyResources((object) this._nameSpaceIndex, "_nameSpaceIndex");
    this._nameSpaceIndex.IsPortNumericBox = true;
    this._nameSpaceIndex.Name = "_nameSpaceIndex";
    this._nameSpaceIndex.TextChanged += new EventHandler(this._nameSpaceIndex_TextChanged);
    componentResourceManager.ApplyResources((object) this._advancedButton, "_advancedButton");
    this._advancedButton.ImageList = this.m_formImageList;
    this._advancedButton.Name = "_advancedButton";
    this._advancedButton.UseVisualStyleBackColor = true;
    this._advancedButton.Click += new EventHandler(this.advancedButton_Click);
    this.m_formImageList.ImageStream = (ImageListStreamer) componentResourceManager.GetObject("m_formImageList.ImageStream");
    this.m_formImageList.TransparentColor = Color.Transparent;
    this.m_formImageList.Images.SetKeyName(0, "collapse.ico");
    this.m_formImageList.Images.SetKeyName(1, "expand.ico");
    this.m_formImageList.Images.SetKeyName(2, "update32.ico");
    componentResourceManager.ApplyResources((object) this._advancedPanel, "_advancedPanel");
    this._advancedPanel.Controls.Add((Control) this._browseButton);
    this._advancedPanel.Controls.Add((Control) this._port);
    this._advancedPanel.Controls.Add((Control) this._portLabel);
    this._advancedPanel.Controls.Add((Control) this.borderlabel);
    this._advancedPanel.Controls.Add((Control) this._nameSpaceIndexBrowser);
    this._advancedPanel.Controls.Add((Control) this._endPointsComboBox);
    this._advancedPanel.Controls.Add((Control) this._endPointslabel);
    this._advancedPanel.Controls.Add((Control) this._refreshButton);
    this._advancedPanel.Controls.Add((Control) this._hostName);
    this._advancedPanel.Controls.Add((Control) this._hostNameLabel);
    this._advancedPanel.Name = "_advancedPanel";
    componentResourceManager.ApplyResources((object) this._browseButton, "_browseButton");
    this._browseButton.Name = "_browseButton";
    this._browseButton.UseVisualStyleBackColor = true;
    this._browseButton.Click += new EventHandler(this._browseButton_Click);
    this._port.AllowSpace = false;
    componentResourceManager.ApplyResources((object) this._port, "_port");
    this._port.IsPortNumericBox = true;
    this._port.Name = "_port";
    componentResourceManager.ApplyResources((object) this._portLabel, "_portLabel");
    this._portLabel.Name = "_portLabel";
    componentResourceManager.ApplyResources((object) this.borderlabel, "borderlabel");
    this.borderlabel.BackColor = SystemColors.ControlLight;
    this.borderlabel.BorderStyle = BorderStyle.Fixed3D;
    this.borderlabel.Name = "borderlabel";
    componentResourceManager.ApplyResources((object) this._nameSpaceIndexBrowser, "_nameSpaceIndexBrowser");
    this._nameSpaceIndexBrowser.Name = "_nameSpaceIndexBrowser";
    this._nameSpaceIndexBrowser.RebrowseOnNodeExpande = false;
    this._nameSpaceIndexBrowser.Server = (OpcUAServer) null;
    componentResourceManager.ApplyResources((object) this._endPointsComboBox, "_endPointsComboBox");
    this._endPointsComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
    this._endPointsComboBox.FormattingEnabled = true;
    this._endPointsComboBox.Name = "_endPointsComboBox";
    this._endPointsComboBox.SelectedIndexChanged += new EventHandler(this._endPointsComboBox_SelectedIndexChanged);
    componentResourceManager.ApplyResources((object) this._endPointslabel, "_endPointslabel");
    this._endPointslabel.Name = "_endPointslabel";
    componentResourceManager.ApplyResources((object) this._refreshButton, "_refreshButton");
    this._refreshButton.ImageList = this.m_formImageList;
    this._refreshButton.Name = "_refreshButton";
    this._refreshButton.UseVisualStyleBackColor = true;
    this._refreshButton.Click += new EventHandler(this._refreshButton_Click);
    componentResourceManager.ApplyResources((object) this._hostName, "_hostName");
    this._hostName.Name = "_hostName";
    this._hostName.KeyPress += new KeyPressEventHandler(this._hostName_KeyPress);
    componentResourceManager.ApplyResources((object) this._hostNameLabel, "_hostNameLabel");
    this._hostNameLabel.Name = "_hostNameLabel";
    componentResourceManager.ApplyResources((object) this.m_warningPictureBox, "m_warningPictureBox");
    this.m_warningPictureBox.Name = "m_warningPictureBox";
    this.m_warningPictureBox.TabStop = false;
    componentResourceManager.ApplyResources((object) this._warningPanel, "_warningPanel");
    this._warningPanel.BackColor = SystemColors.ActiveBorder;
    this._warningPanel.BorderStyle = BorderStyle.FixedSingle;
    this._warningPanel.Controls.Add((Control) this._warningTextBox);
    this._warningPanel.Controls.Add((Control) this.m_warningPictureBox);
    this._warningPanel.Name = "_warningPanel";
    this._warningTextBox.BackColor = SystemColors.ActiveBorder;
    this._warningTextBox.BorderStyle = BorderStyle.None;
    componentResourceManager.ApplyResources((object) this._warningTextBox, "_warningTextBox");
    this._warningTextBox.Name = "_warningTextBox";
    this._warningTextBox.ReadOnly = true;
    componentResourceManager.ApplyResources((object) this, "$this");
    ((ContainerControl) this).AutoScaleMode = AutoScaleMode.Font;
    ((Form) this).CancelButton = (IButtonControl) this._cancelButton;
    ((Control) this).Controls.Add((Control) this._warningPanel);
    ((Control) this).Controls.Add((Control) this._advancedPanel);
    ((Control) this).Controls.Add((Control) this._advancedButton);
    ((Control) this).Controls.Add((Control) this._simpleModePanel);
    ((Control) this).Controls.Add((Control) this._okButton);
    ((Control) this).Controls.Add((Control) this._cancelButton);
    ((Form) this).MaximizeBox = false;
    ((Form) this).MinimizeBox = false;
    ((Control) this).Name = nameof (CUiCOpcUAConnectionForm);
    ((Form) this).ShowIcon = false;
    ((Form) this).SizeGripStyle = SizeGripStyle.Hide;
    ((Form) this).FormClosing += new FormClosingEventHandler(this.CUiCOpcUAConnectionForm_FormClosing);
    this._simpleModePanel.ResumeLayout(false);
    this._simpleModePanel.PerformLayout();
    this._advancedPanel.ResumeLayout(false);
    this._advancedPanel.PerformLayout();
    ((ISupportInitialize) this.m_warningPictureBox).EndInit();
    this._warningPanel.ResumeLayout(false);
    this._warningPanel.PerformLayout();
    ((Control) this).ResumeLayout(false);
    ((Control) this).PerformLayout();
  }
}
